package com.wing.visual.controller;

import com.wing.common.utils.JsonResult;
import com.wing.visual.service.PurchaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * 采购可视化
 *
 * @author xiayang
 */
@Validated
@Api(value = "采购可视化管理", tags = "#/visual/purchase")
@RestController("visualPurchaseController")
@RequestMapping("visual/admin/purchase")
public class PurchaseController {

    @Resource
    PurchaseService purchaseService;

    @ApiOperation(value = "采购订单统计", notes = "采购订单统计")
    @GetMapping("/purchaseTotal")
    public JsonResult purchaseTotal(Integer queryType) {
        Map<String, Object> params = new HashMap<>();
        params.put("queryType", queryType);
        return JsonResult.success(purchaseService.purchaseTotal(params));
    }

    @ApiOperation(value = "订单进度", notes = "订单进度")
    @GetMapping("/purchaseOrderRate")
    public JsonResult purchaseOrderRate(Integer queryType) {
        Map<String, Object> params = new HashMap<>();
        params.put("queryType", queryType);
        return JsonResult.success(purchaseService.purchaseOrderRate(params));
    }

    @ApiOperation(value = "采购订单类型金额统计", notes = "采购订单类型金额统计")
    @GetMapping("/purchaseOrderTypeAmountTotal")
    public JsonResult purchaseOrderTypeAmountTotal(Integer queryType) {
        Map<String, Object> params = new HashMap<>();
        params.put("queryType", queryType);
        return JsonResult.success(purchaseService.purchaseOrderTypeAmountTotal(params));
    }

    @ApiOperation(value = "供应商采购订单金额统计", notes = "供应商采购订单金额统计")
    @GetMapping("/supplierPurchaseAmountTotal")
    public JsonResult supplierPurchaseAmountTotal(Integer queryType) {
        Map<String, Object> params = new HashMap<>();
        params.put("queryType", queryType);
        return JsonResult.success(purchaseService.supplierPurchaseAmountTotal(params));
    }

    @ApiOperation(value = "采购金额曲线图", notes = "采购金额曲线图")
    @GetMapping("/purchaseOrderAmountGraph")
    public JsonResult purchaseOrderAmountGraph() {
        return JsonResult.success(purchaseService.purchaseOrderAmountGraph());
    }

    @ApiOperation(value = "采购订单物料统计", notes = "采购订单物料统计")
    @GetMapping("/materialTotal")
    public JsonResult materialTotal(Integer queryType) {
        Map<String, Object> params = new HashMap<>();
        params.put("queryType", queryType);
        return JsonResult.success(purchaseService.materialTotal(params));
    }
}
